<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<div class="modal-body">
    <div class="row">
        <div class="col-md-12">
            <div style="width:100%;min-height:500px;border:#ccc solid 1px;" id="dituContent"></div>
        </div>
    </div>
</div>
<div class="modal-footer">
    <button id="dialog-ok" class="btn btn-primary" data-dismiss="modal" >确定</button>
    <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
</div>
<script type="text/javascript">
    loadScript("../resource/com/js/CityList.js", loadSelect);
    function loadSelect(){
        initMap();//创建和初始化地图

    }
    //创建和初始化地图函数：
    function initMap(){
        createMap();//创建地图
        setMapEvent();//设置地图事件
        //addMapControl();//向地图添加控件
        //addMarker();//向地图中添加marker
    }

    //创建地图函数：
    function createMap(){
        var map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图
        var point = new BMap.Point(121.487899,31.249162);//定义一个中心点坐标
        map.centerAndZoom(point,13);//设定地图的中心点和坐标并将地图显示在地图容器中
        window.map = map;//将map变量存储在全局

        //自适应高宽
        resizeMap();
    }
    $(function(){
        $(window).resize(function(){
            resizeMap();
        });
    })
    function resizeMap(){
        if($('#dituContent').length){
            //屏幕总高度 - 左上角高度
            var totalheight=$(window).height();
            var totalwidth=$(window).width();
            var X = $('#dituContent').offset().top;
            var Y = $('#dituContent').offset().left;
            var nowHeight=totalheight - X;
            var nowWidth = totalwidth -Y - 10;
            // alert("查询:"+qheight+"body:"+$(document.body).height()+"浏览器文档："+$(document).height()+"浏览器:"+$(window).height()+"地图:"+nowHeight+"可见区域:"+document.body.clientHeight);
            $("#dituContent").height(nowHeight);
            $("#dituContent").width(nowWidth);
            //dituContent
        }
    }
    function setMapEvent(){
        map.enableDragging();//启用地图拖拽事件，默认启用(可不写)
        map.enableDoubleClickZoom();//启用鼠标双击放大，默认启用(可不写)
        map.enableKeyboard();//启用键盘上下左右键移动地图
        map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
        map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL}));  //右上角，仅包含平移和缩放按钮
        map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT, type: BMAP_NAVIGATION_CONTROL_PAN}));  //左下角，仅包含平移按钮
        map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_ZOOM}));  //右下角，仅包含缩放按钮
        map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
        map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用

        //向地图中添加缩略图控件
        var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1});
        map.addControl(ctrl_ove);
        //向地图中添加比例尺控件
        var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
        map.addControl(ctrl_sca);
    }


</script>

